package com.itboye.eweilisten.responsitory;

import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.Log;

import com.google.gson.reflect.TypeToken;
import com.itboye.eweilisten.app.MyApplication;
import com.itboye.eweilisten.interfaces.IUserInfoInterface;
import com.itboye.eweilisten.me.personal.model.PersonDataBean;
import com.itboye.eweilisten.model.AddressBean;
import com.itboye.eweilisten.model.DeviceBean;
import com.itboye.eweilisten.model.DiaoChaBean;
import com.itboye.eweilisten.model.GoPayBean;
import com.itboye.eweilisten.model.GoodsDetailBean;
import com.itboye.eweilisten.model.GuessBooks;
import com.itboye.eweilisten.model.Homebean;
import com.itboye.eweilisten.model.MyBookBean;
import com.itboye.eweilisten.model.MyBooksBeans;
import com.itboye.eweilisten.model.OrderDetalisBean;
import com.itboye.eweilisten.model.QuestionBean;
import com.itboye.eweilisten.model.SchoolBean;
import com.itboye.eweilisten.model.SouSuoBean;
import com.itboye.eweilisten.model.TextABean;
import com.itboye.eweilisten.model.WeiXinPayBean;
import com.itboye.eweilisten.model.YesCuoBean;
import com.itboye.eweilisten.model.ZhangHuBean;
import com.itboye.eweilisten.volley.BaseErrorListener;
import com.itboye.eweilisten.volley.BaseNetRepository;
import com.itboye.eweilisten.volley.BaseSuccessReqListener;
import com.itboye.eweilisten.volley.ByJsonRequest;
import com.itboye.eweilisten.volley.ICompleteListener;

import java.lang.reflect.Array;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Created by admin on 2016/11/28.
 */

public class UserResponsitory extends BaseNetRepository implements
        IUserInfoInterface<PersonDataBean> {
    String api = "103";//接口版本号
    String loginTypeKey = "By_User_login";// 用户登录
    String register = "By_User_register";//用户注册
    private String sendVertificationCode = "By_SecurityCode_create";//发送验证码
    private String YanZheng = "By_SecurityCode_check";//验证码验证
    private String Diaocha = "By_Suggest_survey";//调查
    private String Tijiao = "By_Suggest_surveySubmit";//提交问卷
    private String PASSWORD = "By_User_updatePwd";//密码修改
    private String UpdateEmail = "By_User_changeEmail";//邮箱修改
    private String SCHOOL = "By_User_getSchool";//获取学校
    private String Dtree = "By_User_getDtree";//更新资料
    private String ZiDong = "By_User_autoLogin";//自动登录
    private String Update = "By_User_update";//修改更新资料
    private String Device = "By_LoginDevice_bindList";//已经登录设备查询
    private String DeleteDevice = "By_LoginDevice_unbind";//删除设备
    private String UpdatePwd = "By_User_updatePwdByOldPwd";//修改密码
    private String Home = "By_Index_index";//首页
    private String GoodsInfo = "By_Product_detail";//商品详情
    private String Plilay = "By_Order_createNowEachOne";//立即支付
    private String chongxinPlilay = "By_Order_repay";//重新支付
    private String Order = "By_Order_query";//全部订单查询
    private String CanlerOrder = "By_Order_cancel";//取消订单
    private String UpdatePhone = "By_User_changeMobile";//取消订单OrderDetalis
    private String OrderDetalis = "By_Order_detail";//订单详情
    private String MyBooks = "By_Product_search";//我的书籍
    private String TextA = "By_Question_unitDetail";//TextABean
    private String SchoolPrero = "By_Question_doneList";//错题
    private String TimeError = "By_Question_doneList";//错题
    private String SouSuo = "By_Question_preSearch";//搜索
    private String submitDetail = "By_Question_submitDetail";//对错预览
    private String deleteDaTi = "By_Question_submitUnitDel";//删除答题
    private String yigouBook = "By_Product_myBooks";//已购书籍

    private String weixinPay = "By_Wxpay_prePay";//微信支付
    private String GuessLike = "By_Product_group";//猜你喜欢

    public UserResponsitory(ICompleteListener iCompleteListener) {
        super(iCompleteListener);
    }

    @Override
    public void login(String username, String pwd) {
        Type type = new TypeToken<PersonDataBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("username", username);
        map.put("password", pwd);
        map.put("device_type", "android");
        map.put("device_model", getHandSetInfo());
        Log.d("getHandSetInfo", getDeviceToken());
        map.put("device_token", getDeviceToken());
        (new ByJsonRequest.Builder<PersonDataBean>())
                .setTypeVerParamsAndReturnClass(loginTypeKey, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<PersonDataBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onRefister(String code, String mobile, String username, String password) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("code", code);
        map.put("mobile", mobile);
        map.put("username", username);
        map.put("password", password);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(register, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onSecurCode(String acceptor, String code_type) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("acceptor", acceptor);
        map.put("code_type", code_type);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(sendVertificationCode, "101", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onDiaocha(String uid,String s_id) {
        Type type = new TypeToken<List<DiaoChaBean>>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        (new ByJsonRequest.Builder<List<DiaoChaBean>>())
                .setTypeVerParamsAndReturnClass(Diaocha, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<List<DiaoChaBean>>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onTiJiaoWenJuan(String answer,String uid,String s_id) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("answer", answer);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(Tijiao, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onYanZhengMa(String acceptor, String code, String code_type,String uid,String s_id) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("acceptor", acceptor);
        map.put("code", code);
        map.put("code_type", code_type);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(YanZheng, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    /**
     * 修改密码
     *
     * @param s_id
     * @param code
     * @param email
     * @param password
     */
    @Override
    public void onPassWord(String s_id, String code, String email, String password,String uid) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("s_id", s_id);
        map.put("code", code);
        map.put("email", email);
        map.put("password", password);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(PASSWORD, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onUpdateemil(String email, String new_email, String code,String new_code,String uid,String s_id) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("email", email);
        map.put("new_email", new_email);
        map.put("code", code);
        map.put("new_code",new_code);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(UpdateEmail, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onSchool(String area_id,String uid,String s_id) {
        Type type = new TypeToken<List<AddressBean>>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("area_id", area_id);
        (new ByJsonRequest.Builder<List<AddressBean>>())
                .setTypeVerParamsAndReturnClass(SCHOOL, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<List<AddressBean>>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onQuestion(String uid,String s_id) {
        Type type = new TypeToken<QuestionBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        (new ByJsonRequest.Builder<QuestionBean>())
                .setTypeVerParamsAndReturnClass(Dtree, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<QuestionBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onHeadQuestion(String uid,String s_id) {
        Type type = new TypeToken<QuestionBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        (new ByJsonRequest.Builder<QuestionBean>())
                .setTypeVerParamsAndReturnClass(Dtree, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<QuestionBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onUpdateUser(String s_id, String uid, String nickname, String sex, String sign, String head, String grade_code, String loc_school, String loc_country, String loc_area) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("s_id", s_id);
        map.put("uid", uid);
        map.put("nickname", nickname);
        map.put("sign", sign);
        map.put("sex", sex);
        map.put("head", head);
        map.put("grade_code", grade_code);
        map.put("loc_school", loc_school);
        map.put("loc_country", loc_country);
        map.put("loc_area", loc_area);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(Update, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onAutoLogin(String uid, String auto_login_code) {
        Type type = new TypeToken<PersonDataBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("auto_login_code", auto_login_code);
//        map.put("role","");
        (new ByJsonRequest.Builder<PersonDataBean>())
                .setTypeVerParamsAndReturnClass(ZiDong, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<PersonDataBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onDevice(String uid,String s_id) {
        Type type = new TypeToken<List<DeviceBean>>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        (new ByJsonRequest.Builder<List<DeviceBean>>())
                .setTypeVerParamsAndReturnClass(Device, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<List<DeviceBean>>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onDeleteDevice(String s_id, String uid, String device_token) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("s_id", s_id);
        map.put("uid", uid);
        map.put("device_token", device_token);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(DeleteDevice, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onHomeLunbo(String size,String uid,String s_id) {
        Type type = new TypeToken<Homebean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("position", size);
        (new ByJsonRequest.Builder<Homebean>())
                .setTypeVerParamsAndReturnClass(Home, "101", map, type)
                .requestListener(
                        new BaseSuccessReqListener<Homebean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onUpdatePwd(String s_id, String uid, String password, String new_password) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("s_id", s_id);
        map.put("uid", uid);
        map.put("password", password);
        map.put("new_password", new_password);
//        map.put("role","");
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(UpdatePwd, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onGoodsInfo(String id, String uid,String s_id) {
        Type type = new TypeToken<GoodsDetailBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("uid", uid);
        (new ByJsonRequest.Builder<GoodsDetailBean>())
                .setTypeVerParamsAndReturnClass(GoodsInfo, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<GoodsDetailBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onGoodsInfoLie(String id, String uid,String s_id) {
        Type type = new TypeToken<GoodsDetailBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("uid", uid);
        (new ByJsonRequest.Builder<GoodsDetailBean>())
                .setTypeVerParamsAndReturnClass(GoodsInfo, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<GoodsDetailBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onPlipay(String idcode, String s_id, String uid, String sku_pkid, String note) {
        Type type = new TypeToken<GoPayBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("idcode", idcode);
        map.put("s_id", s_id);
        map.put("uid", uid);
        map.put("sku_pkid", sku_pkid);
        map.put("note", note);
        (new ByJsonRequest.Builder<GoPayBean>())
                .setTypeVerParamsAndReturnClass(Plilay, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<GoPayBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void chongxinPlipay(String s_id, String uid, String order_code) {
        Type type = new TypeToken<GoPayBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("s_id", s_id);
        map.put("uid", uid);
        map.put("order_code", order_code);
        (new ByJsonRequest.Builder<GoPayBean>())
                .setTypeVerParamsAndReturnClass(chongxinPlilay, "101", map, type)
                .requestListener(
                        new BaseSuccessReqListener<GoPayBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    /**
     * 微信支付
     *
     * @param pay_code
     */
    @Override
    public void onWeiXinPay(String pay_code,String uid,String s_id) {
        Type type = new TypeToken<WeiXinPayBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("pay_code", pay_code);
        (new ByJsonRequest.Builder<WeiXinPayBean>())
                .setTypeVerParamsAndReturnClass(weixinPay, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<WeiXinPayBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onOrder(String s_id, String uid, String keyword, String query_status, String page_index, String page_size) {
        Type type = new TypeToken<ZhangHuBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("s_id", s_id);
        map.put("uid", uid);
        map.put("keyword", "");
        map.put("query_status", query_status);
        map.put("page_index", page_index);
        map.put("page_size", page_size);
        (new ByJsonRequest.Builder<ZhangHuBean>())
                .setTypeVerParamsAndReturnClass(Order, "101", map, type)
                .requestListener(new BaseSuccessReqListener<ZhangHuBean>(getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onCanlerOrder(String s_id, String uid, String order_code) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("s_id", s_id);
        map.put("uid", uid);
        map.put("order_code", order_code);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(CanlerOrder, "101", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onUpdatePhone(String s_id, String uid, String mobile, String mobile_new) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("s_id", s_id);
        map.put("uid", uid);
        map.put("mobile", mobile);
        map.put("mobile_new", mobile_new);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(UpdatePhone, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onOrderDetails(String s_id, String uid, String orderNum) {
        Type type = new TypeToken<OrderDetalisBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("s_id", s_id);
        map.put("uid", uid);
        map.put("order_code", orderNum);
        (new ByJsonRequest.Builder<OrderDetalisBean>())
                .setTypeVerParamsAndReturnClass(OrderDetalis, "101", map, type)
                .requestListener(
                        new BaseSuccessReqListener<OrderDetalisBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onMyBooks(String uid, String pageNum, String pageSize,String s_id) {
        Type type = new TypeToken<MyBooksBeans>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("page_index", pageNum);
        map.put("page_size", pageSize);
        (new ByJsonRequest.Builder<MyBooksBeans>())
                .setTypeVerParamsAndReturnClass(MyBooks, "101", map, type)
                .requestListener(
                        new BaseSuccessReqListener<MyBooksBeans>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onTimu(String uid, String unit_id, String s_id) {
        Type type = new TypeToken<TextABean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("unit_id", unit_id);
        map.put("s_id", s_id);
        (new ByJsonRequest.Builder<TextABean>())
                .setTypeVerParamsAndReturnClass(TextA, "101", map, type)
                .requestListener(
                        new BaseSuccessReqListener<TextABean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onSchoolRepor(String uid, String answer_type, String book_id, String unit_id, String order, String current_page, String page_size,String s_id) {
        Type type = new TypeToken<SchoolBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("answer_type", answer_type);
        map.put("book_id", book_id);
        map.put("unit_id", unit_id);
        map.put("order", order);
        map.put("current_page", current_page);
        map.put("page_size", page_size);
        (new ByJsonRequest.Builder<SchoolBean>())
                .setTypeVerParamsAndReturnClass(SchoolPrero, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<SchoolBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onSchoolReporTwo(String uid, String answer_type, String book_id, String unit_id, String order, String current_page, String page_size,String s_id) {
        Type type = new TypeToken<SchoolBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("answer_type", answer_type);
        map.put("book_id", book_id);
        map.put("unit_id", unit_id);
        map.put("order", order);
        map.put("current_page", current_page);
        map.put("page_size", page_size);
        (new ByJsonRequest.Builder<SchoolBean>())
                .setTypeVerParamsAndReturnClass(TimeError, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<SchoolBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onPreSearch(String uid, String kword, String book_id, String page_size,String s_id) {
        Type type = new TypeToken<List<SouSuoBean>>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("kword", kword);
        map.put("book_id", book_id);
        map.put("page_size", page_size);

        (new ByJsonRequest.Builder<List<SouSuoBean>>())
                .setTypeVerParamsAndReturnClass(SouSuo, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<List<SouSuoBean>>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onSubmitDetail(String uid, String unit_id, String id,String s_id) {
        Type type = new TypeToken<YesCuoBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);
        map.put("unit_id", unit_id);
        (new ByJsonRequest.Builder<YesCuoBean>())
                .setTypeVerParamsAndReturnClass(submitDetail, "101", map, type)
                .requestListener(
                        new BaseSuccessReqListener<YesCuoBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    /**
     * 删除答题
     */
    @Override
    public void onDelet(String uid, String id,String s_id) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(deleteDaTi, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onYiMaiBook(String uid, String kword, String cate_id, String page_index, String page_size,String s_id) {
        Type type = new TypeToken<MyBookBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("kword", kword);
        map.put("cate_id", cate_id);
        map.put("page_index", page_index);
        map.put("page_size", page_size);
        (new ByJsonRequest.Builder<MyBookBean>())
                .setTypeVerParamsAndReturnClass(yigouBook, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<MyBookBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onGuessLike(String size, String page, String group,String uid,String s_id) {
        Type type=new TypeToken<GuessBooks>(){}.getType();
        Map<String,Object> map=new HashMap<>();
        map.put("size",size);
        map.put("page",page);
        map.put("group",group);
        (new ByJsonRequest.Builder<GuessBooks>())
                .setTypeVerParamsAndReturnClass(GuessLike, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<GuessBooks>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    public static String getDeviceToken() {
        TelephonyManager tm = (TelephonyManager) MyApplication.getInstance().getSystemService(Context.TELEPHONY_SERVICE);
        String DEVICE_ID = tm.getDeviceId();
        return DEVICE_ID;
    }

    /**
     * 获取设备型号
     *
     * @return
     */
    private String getHandSetInfo() {
        String handSetInfo = android.os.Build.MODEL;
        return handSetInfo;
    }
}
